// pages/student_m_report_box/student_m_report_box.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    boxId:"",
    box:{},
    scoreItems:[],
    scoreItemVisible:false,
    selectedScoreItem:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    if (options != null){
      const boxId= options.boxId;
      this.setData({boxId})
      var that = this;
      wx.request({
        url: app.globalData.url+'/wechat/box?boxId='+boxId,
        method: 'get',
        success: res2 => {
          const scoreItems=res2.data&&res2.data.scoreItems
          this.setData({
            box:res2.data||{},
            scoreItems,
            selectedScoreItem:scoreItems[0]&&scoreItems[0]
          });
            wx.setNavigationBarTitle({
            title: res2.data&&res2.data.name||"未查到作业箱"
        })
        }
      })
      
    }
  },
  onPickScoreItem:function(e){
    const selectedScoreItem=e.target.id;
  
    app.globalData.score_item=selectedScoreItem
    this.setData({selectedScoreItem})
  },
  onClickPicker:function(){
    console.log('onClickPicker',this.data.scoreItems)
    this.setData({scoreItemVisible:true})
  },
  onPickerCancel:function(){
    this.setData({scoreItemVisible:false})
  },
  click_prepare:function(){
    wx.showToast({
      title: '功能开发中。。。',
      icon: 'none',
      duration: 2000
    })
  },
  upload_resource:function(){
    wx.navigateTo({
      url: "../student_report/report?boxId="+this.data.boxId+"&score_item="+this.data.selectedScoreItem,
    })
  },
  upload_report:function(){
    wx.navigateTo({
      url: "../report_score_item/report?boxId="+this.data.boxId+"&score_item="+this.data.selectedScoreItem,
    })
  },
})